<?php

/**
 * 用户后台管理
 * Created by PhpStorm.
 * User: yh
 * Date: 2017/6/7
 * Time: 11:16
 */
class Users extends Web_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('User_model', 'user_model');
    }

    //绑定银行卡
    public function bindBank()
    {
        $uid = $this->input->get('uid');
        $cardid = $this->input->get('cardid');
        $bankid = $this->input->get('bankid');
        $username = $this->input->get('username');
        $this->user_model->bindBank($uid,$cardid,$bankid,$username);

    }


    //添加默认地址
    public function addDefaultUserAddress()
    {
        $user = $this->userSession(true, 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
//        $user = (object)array('uid' => '1');
        $uid = $user->uid;
        $address_id = $this->input->post('address_id');
        $did = $this->user_model->setAddressid($uid,$address_id);
        if($did)
        {
            echo json_encode(array('result' => 0));
        }else
        {
            echo json_encode(array('result' => 1,'errmsg' => '设置默认地址失败'));
        }

    }


}